{template 'common/header'}

<ul class="nav nav-tabs">
	{if $cattype == 1}
		<li {if $operation == 'display'}class="active"{/if}><a href="{php echo $this->createWebUrl('itemcate',array('op' =>'display','cattype'=>1))}">商品分类管理</a></li>
		<li {if empty($othercat['id']) && $operation == 'post'}class="active"{/if}><a href="{php echo $this->createWebUrl('itemcate',array('op' =>'post','cattype'=>1))}">添加商品分类</a></li>
		{if !empty($othercat['id']) &&  $operation == 'post'}<li class="active"><a href="###">编辑商品分类</a></li>{/if}
	{/if}
</ul>

{if $operation == 'display'}
<div class="main panel panel-default">
	<div class="panel-body table-responsive">
		<form action="" method="post">
		<table class="table table-hover">
			<thead class="navbar-inner">
				<tr>
					<th style="width:8%;">排序</th>
					<th style="width:10%;">分类图标</th>
					<th style="width:30%;">分类名称</th>
					<th>所属类型</th>
					<th style="width:6%;">状态</th>
					<th style="text-align:right;">操作</th>
				</tr>
			</thead>
			<tbody>
				{loop $list $othercat}
				<tr>
					<td><input class="form-control" name="displayorder[{$othercat['id']}]" value="{$othercat['displayorder']}" type="text"></td>
					<td>{if $othercat['thumb']}<img src="{php echo tomedia($othercat['thumb']);}" width="50" height="50" />{/if}</td>
					<td>
						<span class="label label-success">{$othercat['catename']}</span>
					</td>
					<td>
						<span class="label label-info">
							{if $othercat['cattype'] == 1}商品分类{/if}
						</span>
					</td>
					<td>
						{if $othercat['enabled'] == 1}
							<span class="label label-success">已启用</span>
						{else}
							<span class="label label-danger">未启用</span>
						{/if}
					</td>
					<td style="text-align:right;">
						<a href="{php echo $this->createWebUrl('itemcate', array('op' => 'post', 'id' => $othercat['id'],'cattype'=>$cattype))}" class="btn btn-default btn-sm" title="修改"><i class="fa fa-edit"></i></a>
						<a href="{php echo $this->createWebUrl('itemcate', array('op' => 'delete', 'id' => $othercat['id']))}"class="btn btn-default btn-sm" onclick="return confirm('此操作不可恢复，确认删除？');return false;" data-toggle="tooltip" data-placement="top" title="删除"><i class="fa fa-times"></i></a>
					</td>
				</tr>
				    {loop $othercat['erji'] $row}
					<tr>
						<td><input class="form-control" name="displayorder[{$row['id']}]" value="{$row['displayorder']}" type="text"></td>
						<td></td>
						<td>
							<div style="padding-left:50px;height:30px;line-height:30px;background:url('./resource/images/bg_repno.gif') no-repeat -245px -545px;">{if $row['thumb']}<img src="{php echo tomedia($row['thumb']);}" style="margin-right:5px;" width="30" height="30" />{/if}<span class="label label-success">{$row['catename']}</span></div>
						</td>
						<td>
							<span class="label label-info">
								{if $row['cattype'] == 1}商品分类{/if}
							</span>
						</td>
						<td>
							{if $row['enabled'] == 1}
								<span class="label label-success">已启用</span>
							{else}
								<span class="label label-danger">未启用</span>
							{/if}
						</td>
						<td style="text-align:right;">
							<a href="{php echo $this->createWebUrl('itemcate', array('op' => 'post', fid=>$row['fid'],'id' => $row['id'],'cattype'=>$cattype))}" class="btn btn-default btn-sm" title="修改"><i class="fa fa-edit"></i></a>
							<a href="{php echo $this->createWebUrl('itemcate', array('op' => 'delete', 'id' => $row['id']))}"class="btn btn-default btn-sm" onclick="return confirm('此操作不可恢复，确认删除？');return false;" data-toggle="tooltip" data-placement="top" title="删除"><i class="fa fa-times"></i></a>
						</td>
					</tr>
					{/loop}
					
				{/loop}
				<tr>
					<td colspan="6">
						<input name="token" value="{$_W['token']}" type="hidden">
						<input name="op" value="display" type="hidden">
						<input name="cattype" value="{$cattype}" type="hidden">
						<input name="submit" class="btn btn-primary" value="修改排序" type="submit">
					</td>
				</tr>
			</tbody>
		</table>
		</form>
	</div>
</div>
{elseif $operation == 'post'}
<div class="main">
	<form action="" method="post" class="form-horizontal form" enctype="multipart/form-data">
		<input type="hidden" name="id" value="{$othercat['id']}" />
		<input type="hidden" name="cattype" value="{$cattype}" />
		<div class="panel panel-default">
			<div class="panel-heading">分类设置</div>
			<div class="panel-body">
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">排序</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="displayorder" class="form-control" value="{$othercat['displayorder']}" />
						<span class="help-block" style="color:red;">降序</span>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">分类名称</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="catename" class="form-control" value="{$othercat['catename']}" />
					</div>
				</div>
				
				{if $fid > 0 && $cattype == 1}
					<div class="form-group">
						<label class="col-xs-12 col-sm-3 col-md-2 control-label">上级分类</label>
						<div class="col-sm-9 col-xs-12">
							<select name="fid" class="form-control">
								<option value="请选择">选择上级分类</option>
								{loop $catlist $cat}
								<option value="{$cat['id']}" {if $cat['id'] == $fid}selected="selected"{/if}>{$cat['catename']}</option>
								{/loop}
							</select>
						</div>
					</div>
				{/if}

				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">分类图标</label>
					<div class="col-sm-9 col-xs-12">
						{php echo tpl_form_field_image('thumb', $othercat['thumb'], '', array('extras' => array('text' => 'readonly')))}
						<span class="help-block" style="color:red;">推荐尺寸200*200</span>
					</div>
				</div>
				
				
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">是否启用</label>
					<div class="col-sm-9 col-xs-12">
						<label class="radio-inline"><input type="radio" name="enabled" value="1" {if $othercat['enabled'] == 1}checked="true"{/if} /> 启用</label>
						&nbsp;&nbsp;&nbsp;
						<label class="radio-inline"><input type="radio" name="enabled" value="0" {if $othercat['enabled'] == 0}checked="true"{/if} /> 不启用</label>					
					</div>
				</div>
			</div>
		</div>

		<div class="form-group col-sm-12">
			<input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1" />
			<input type="hidden" name="token" value="{$_W['token']}" />
		</div>
	</form>
</div>
{/if}
{template 'common/footer'}